<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
cfc('core')->checklogin();
if($_RQ['op']=='get'){
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid']));
	$data['allfee']=pdo_getsum('jy_ad_feelog',array('type'=>array(3,4),'mid'=>$_SESSION['uid']),'fee');
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$data['dayfee']=pdo_getsum('jy_ad_feelog',array('type'=>array(3,4),'mid'=>$_SESSION['uid'],'createtime >'=>$daytime),'fee');
	$data['tixian']=$member['credit2'];
	$data['commission_total']=pdo_getsum('jy_ad_feelog',array('type'=>array(3,4),'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'fee');
	$return['data']=$data;
	$return['member']=$member;
	$member=$this->get('member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$return['member2']=$member;
	$level=$this->get('teamlevel',array('id'=>$member['level_id']));
	$parameter=array(
			'params'=>array('uniacid'=>$_SESSION['uniacid'],'level >'=>$level['level']),
			'orderby'=>'level asc',
			'limit'=>'1',
	);
	$levels=$this->get_list('teamlevel',$parameter);
	$next_level=$levels[0];
	if($level['id']){
		$commissions=json_decode($level['commissions'],true);
		$tips='您当前等级是《'.$level['title'].'》,享受直推佣金['.$commissions['commission_0'].'],享受间推佣金['.$commissions['commission_0'].'],享受上级佣金['.$commissions['shangji'].']（不同的商品，所有差异！）';
	}else{
		$commissions=json_decode($next_level['commissions'],true);
		$tips='您当前等级是《默认等级》，再推荐['.$next_level['fennum'].']人,可升级为《'.$next_level['title'].'》,享受直推佣金['.$commissions['commission_0'].'],享受间推佣金['.$commissions['commission_0'].'],享受上级佣金['.$commissions['shangji'].']（不同的商品，所有差异！）';
	}
	$return['tips']=$tips;
	$renwu['yuefee']=pdo_getsum('jy_ad_log',array('adwei'=>1,'mid'=>$_SESSION['uid'],'createtime >'=>$daytime),'fee');
	$renwu['fullfee']=pdo_getsum('jy_ad_log',array('adwei'=>4,'mid'=>$_SESSION['uid'],'createtime >'=>$daytime),'fee');
	$renwu['videofee']=pdo_getsum('jy_ad_log',array('adwei'=>5,'mid'=>$_SESSION['uid'],'createtime >'=>$daytime),'fee');
	$renwu['downfee']=pdo_getsum('jy_ad_log',array('adwei'=>6,'mid'=>$_SESSION['uid'],'createtime >'=>$daytime),'fee');
	$return['renwu']=$renwu;
	$return['level']=$level?:array();
	$return['params']['type']=$_RQ['type']?:'0';
	set_html('title','我的任务');
	exi($return);
}
if($_RQ['op']=='post'){
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid']));
	$post=get_postdata();
	if(!$post['fee']){
		exi('请输入转账金额！','erroe');
	}
	if(!$post['mobile']){
		exi('请输入收款人账户/手机号！','erroe');
	}
	if(!$post['password']){
		exi('请输入支付密码！','erroe');
	}
	if($post['password']!=$member['paypassword']){
		exi('支付密码不正确！','erroe');
	}
	if($member['credit2']<$post['fee']){
		exi('转账额度不能大于，当前余额！','erroe');
	}
	$tomember=pdo_get('core_members',array('username'=>$post['mobile']));
	$tomid=$tomember['id'];
	if(!$tomid){
		$tomember=pdo_get('core_members',array('mobile'=>$post['mobile']));
		$tomid=$tomember['onemid']?:$tomember['id'];
	}
	if(!$tomid){
		exi('没找到收款人，转账失败！','erroe');
	}
	model('core/member')->cut_credit2($_SESSION['uid'],$post['fee'],'转账给:'.$post['mobile']);
	model('core/member')->add_credit2($tomid,$post['fee'],$member['username'].'的转账');
	exi('转账成功！');
}
if($_RQ['op']=='password'){
	$post=get_postdata();
	if(!$post['password']){
		exi('请输入支付密码！','erroe');
	}
	pdo_update('core_members',array('paypassword'=>$post['password']),array('id'=>$_SESSION['uid']));
	exi('设置成功！');
}
if($_RQ['op']=='feelist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	if($_RQ['type']){
		$params['type']=$_RQ['type'];
	}
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_ad_feelog',$params,array($pindex,$psize),$total,$fields,'',$orderby);	
	foreach($return['list'] as &$v){
			$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
			$v['typetitle']=$this->feelog_type[$v['type']];
			$v['statustitle']=$this->commission_status[$v['status']];
	}
	exi($return);
}